home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Source / MiscMergeKit / _MiscMergeIfCommand.m < prev    next >
Encoding:
Text File  |  1995-07-08  |  1.5 KB  |  52 lines

  1. //
  2. //    _MiscMergeIfCommand.m -- "if" merge command implementation
  3. //        Written by Don Yacktman Copyright (c) 1995 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //        This notice may not be removed from this source code.
  6. //
  7. //    This object is included in the MiscKit by permission from the author
  8. //    and its use is governed by the MiscKit license, found in the file
  9. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  10. //    for a list of all applicable permissions and restrictions.
  11. //    
  12.  
  13.  
  14. #import <misckit/miscmerge.h>
  15. #import "_MiscMergeIfCommand.h"
  16.  
  17. @implementation _MiscMergeIfCommand
  18.  
  19. static MiscString *myKey = nil;
  20.  
  21. - parseFromString:(MiscString *)aString
  22. {
  23.     if (!myKey) {
  24.         myKey = [MiscString new];
  25.         [myKey setStringValue:"if"];
  26.     }
  27.     [self eatKeyWord:myKey from:aString isOptional:NO];
  28.     value1 = [self getArgumentStringFrom:aString toEnd:NO];
  29.     operator = [self getConditionalFrom:aString];
  30.     // if none, then we just expect value1 to be a single field
  31.     // and the condition will evaluate true if it is non-empty.
  32.     // (Or, it may be a keyword that always evals true or false...)
  33.     if (operator != MISC_MCO_NONE) {
  34.         value2 = [self getArgumentStringFrom:aString toEnd:YES];
  35.     }
  36.     return self;
  37. }
  38.  
  39. - executeForMerge:(MiscMergeEngine *)aMerger
  40. { // The MiscIfStack object has all the if/then/else logic in it.
  41.     [[aMerger ifStack]
  42.         startIf:[[self class] evaluateConditionWith:aMerger for:self]];
  43.     return self;
  44. }
  45.  
  46. // MiscMergeCondCallback protocol
  47. - value1 { return value1; }
  48. - value2 { return value2; }
  49. - (MISC_Merge_Cond_Op)operator { return operator; }
  50.  
  51. @end
  52.